import pandas as pd
from sklearn.datasets import load_boston
from sklearn.model_selection import train_test_split
from sklearn.pipeline import Pipeline
from sklearn.decomposition import PCA
from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt
data=load_boston()
x=data.data
y=data.target

train_x,test_x,train_y,test_y=train_test_split(x,y,test_size=0.3)

guandao=Pipeline([('abc',PCA(n_components=4)),
                  ('bcd',LinearRegression())])

guandao.fit(train_x,train_y)
print(guandao.score(test_x,test_y))

test_h=guandao.predict(test_x)

plt.plot(sorted(test_y),sorted(test_h))
plt.show()
